<?php


namespace app\shop\command;


use app\shop\common\consts\Consts;
use app\shop\model\user\UserModel;
use app\shop\service\user\UserService;
use yunwuxin\cron\Task;

class RefreshLoginCode extends Task
{
    protected function configure()
    {
        $this->everyThirtyMinutes();
    }

    protected function execute()
    {
        $time = time() - 1800;
        $idArr = UserModel::whereIn('role_id', [Consts::DESIGN_LEADER_ID, Consts::DESIGN_ID])
            ->where('last_refresh_code_time', '<', $time)
            ->column('user_id');
        UserService::generateCode($idArr, 0, 0, 0, 1);
        print "****************刷新登录码成功******************\n";
    }
}